<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Sifteo SDK: sprite.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-style-overrides.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<center>
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Sifteo SDK" src="sdk_logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">
   &#160;<span id="projectnumber">v1.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</center>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Home</span></a></li>
      <li><a href="pages.html"><span>Guides</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Reference</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_12cda917fe1d7c8b4e7d2501bb3636e4.html">sdk</a></li><li class="navelem"><a class="el" href="dir_2f23e30b638d6a5f333babd9a5d183e1.html">include</a></li><li class="navelem"><a class="el" href="dir_d5ace589187da7c83c1a7507ec9fbbef.html">sifteo</a></li><li class="navelem"><a class="el" href="dir_483499650334b406c1d3bbaf3a730f60.html">video</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">sprite.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/* -*- mode: C; c-basic-offset: 4; intent-tabs-mode: nil -*-</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * This file is part of the public interface to the Sifteo SDK.</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Copyright &lt;c&gt; 2012 Sifteo, Inc. All rights reserved.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#ifdef NOT_USERSPACE</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#   error This is a userspace-only header, not allowed by the current build.</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;sifteo/abi.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;sifteo/macros.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;sifteo/math.h&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="keyword">namespace </span>Sifteo {</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html">   39</a></span>&#160;<span class="keyword">struct </span><a class="code" href="struct_sifteo_1_1_sprite_ref.html" title="SpriteRefs refer to a single sprite on a single cube.">SpriteRef</a> {</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    _SYSAttachedVideoBuffer *sys;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <span class="keywordtype">unsigned</span> id;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div>
<div class="line"><a name="l00050"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#ab19c66f2f776fc96eb73a32dc7a60572">   50</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#ab19c66f2f776fc96eb73a32dc7a60572" title="Set the sprite&#39;s image, given the physical address of the first tile in a pinned asset.">setImage</a>(uint16_t tile)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;        uint16_t word = _SYS_TILE77(tile);</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;        uint16_t addr = ( <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, spr[0].tile)/2 +</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;                          <span class="keyword">sizeof</span>(_SYSSpriteInfo)/2 * <span class="keywordtype">id</span> );</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        _SYS_vbuf_poke(&amp;sys-&gt;vbuf, addr, word);</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    }</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div>
<div class="line"><a name="l00061"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a19c9ddc5052a8c984d2fc1b353597114">   61</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a19c9ddc5052a8c984d2fc1b353597114" title="Set a sprite&#39;s image and size, given a PinnedAssetImage and optionally a frame number.">setImage</a>(<span class="keyword">const</span> <a class="code" href="struct_sifteo_1_1_pinned_asset_image.html" title="An AssetImage in which all tiles are stored sequentially in memory.">PinnedAssetImage</a> &amp;asset, <span class="keywordtype">int</span> frame = 0)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;        <a class="code" href="struct_sifteo_1_1_sprite_ref.html#ab19c66f2f776fc96eb73a32dc7a60572" title="Set the sprite&#39;s image, given the physical address of the first tile in a pinned asset.">setImage</a>(asset.<a class="code" href="struct_sifteo_1_1_pinned_asset_image.html#acae95d334dc7ae91830e26cc8389bcb4" title="Returns the index of the tile at linear position &#39;i&#39; in the image.">tile</a>(sys-&gt;cube, <a class="code" href="group__math.html#gab18c9af04a4a3a4a3c63656e40ab74ed" title="Create a Vector2, from a set of (x,y) coordinates.">vec</a>(0,0), frame));</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;        <a class="code" href="struct_sifteo_1_1_sprite_ref.html#ae349912611dc70fed846e387915569f4" title="Set this sprite&#39;s size, in pixels.">resize</a>(asset.<a class="code" href="struct_sifteo_1_1_pinned_asset_image.html#abc69a1ae22681012ba7db2c1b3fb84be" title="The (width, height) vector of this image, in pixels.">pixelSize</a>());</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    }</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div>
<div class="line"><a name="l00069"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a433126a838a5386991f8c8facca17882">   69</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a433126a838a5386991f8c8facca17882" title="Get this sprite&#39;s current image width, in pixels.">width</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        uint16_t addr = ( <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, spr[0].mask_x) +</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;                          <span class="keyword">sizeof</span>(_SYSSpriteInfo) * <span class="keywordtype">id</span> );</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        <span class="keywordflow">return</span> -(int8_t)_SYS_vbuf_peekb(&amp;sys-&gt;vbuf, addr);</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    }</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div>
<div class="line"><a name="l00078"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a158887513cd697fc9afa8cd6346b062b">   78</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a158887513cd697fc9afa8cd6346b062b" title="Get this sprite&#39;s current image height, in pixels.">height</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;        uint16_t addr = ( <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, spr[0].mask_y) +</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;                          <span class="keyword">sizeof</span>(_SYSSpriteInfo) * <span class="keywordtype">id</span> );</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;        <span class="keywordflow">return</span> -(int8_t)_SYS_vbuf_peekb(&amp;sys-&gt;vbuf, addr);</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    }</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;</div>
<div class="line"><a name="l00087"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a911040d2a8ede6625dd80a231c71e7fa">   87</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UByte2</a> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a911040d2a8ede6625dd80a231c71e7fa" title="Get this sprite&#39;s current image size as a vector, in pixels.">size</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;        uint16_t addr = ( <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, spr[0].mask_y)/2 +</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;                          <span class="keyword">sizeof</span>(_SYSSpriteInfo)/2 * <span class="keywordtype">id</span> );</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;        uint16_t word = _SYS_vbuf_peek(&amp;sys-&gt;vbuf, addr);</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;        <span class="keywordflow">return</span> vec&lt;uint8_t&gt;(-(int8_t)(word &gt;&gt; 8), -(int8_t)word);</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    }</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;</div>
<div class="line"><a name="l00097"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a5daccbcf07697e5b5146b9e78c7f464a">   97</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a5daccbcf07697e5b5146b9e78c7f464a" title="Set this sprite&#39;s width, in pixels.">setWidth</a>(<span class="keywordtype">unsigned</span> pixels)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        uint16_t addr = ( <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, spr[0].mask_x) +</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;                          <span class="keyword">sizeof</span>(_SYSSpriteInfo) * <span class="keywordtype">id</span> );</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        _SYS_vbuf_pokeb(&amp;sys-&gt;vbuf, addr, -(int8_t)pixels);</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    }</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;</div>
<div class="line"><a name="l00106"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a0bdcc1b679e5e770663da7881ccb842c">  106</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a0bdcc1b679e5e770663da7881ccb842c" title="Set this sprite&#39;s height, in pixels.">setHeight</a>(<span class="keywordtype">unsigned</span> pixels)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;        uint16_t addr = ( <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, spr[0].mask_y) +</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;                          <span class="keyword">sizeof</span>(_SYSSpriteInfo) * <span class="keywordtype">id</span> );</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;        _SYS_vbuf_pokeb(&amp;sys-&gt;vbuf, addr, -(int8_t)pixels);</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    }</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;</div>
<div class="line"><a name="l00115"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#ae349912611dc70fed846e387915569f4">  115</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#ae349912611dc70fed846e387915569f4" title="Set this sprite&#39;s size, in pixels.">resize</a>(<span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a8cf628cb56a69225c2d92f69fce316e6" title="Get this sprite&#39;s current X position, in pixels.">x</a>, <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a5e181367a4c02d509069b74e8a34ca88" title="Get this sprite&#39;s current Y position, in pixels.">y</a>)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;        <span class="comment">// Size must be a power of two in current firmwares.</span></div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;        <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>((x &amp; (x - 1)) == 0 &amp;&amp; (y &amp; (y - 1)) == 0);</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        _SYS_vbuf_spr_resize(&amp;sys-&gt;vbuf, <span class="keywordtype">id</span>, x, y);</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    }</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;</div>
<div class="line"><a name="l00125"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a7b274dd92adbad00ea6fa0c76fb5ea93">  125</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a7b274dd92adbad00ea6fa0c76fb5ea93" title="Set this sprite&#39;s size, in pixels, from a UInt2.">resize</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">UInt2</a> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a911040d2a8ede6625dd80a231c71e7fa" title="Get this sprite&#39;s current image size as a vector, in pixels.">size</a>)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;        <a class="code" href="struct_sifteo_1_1_sprite_ref.html#ae349912611dc70fed846e387915569f4" title="Set this sprite&#39;s size, in pixels.">resize</a>(size.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a>, size.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>);</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;    }</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;</div>
<div class="line"><a name="l00137"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a9f4f3e9b4624b7b82746477813e9d18b">  137</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a9f4f3e9b4624b7b82746477813e9d18b" title="Is this sprite hidden?">isHidden</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a158887513cd697fc9afa8cd6346b062b" title="Get this sprite&#39;s current image height, in pixels.">height</a>() == 0;</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    }</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;</div>
<div class="line"><a name="l00147"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a34b3553ac6601f469819dfc454edb59d">  147</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a34b3553ac6601f469819dfc454edb59d" title="Hide a sprite.">hide</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;        <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a0bdcc1b679e5e770663da7881ccb842c" title="Set this sprite&#39;s height, in pixels.">setHeight</a>(0);</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;    }</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;</div>
<div class="line"><a name="l00158"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#ac3c4d07b15caa0eecb715555b106709f">  158</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#ac3c4d07b15caa0eecb715555b106709f" title="Move this sprite to a new location, in pixels.">move</a>(<span class="keywordtype">int</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a8cf628cb56a69225c2d92f69fce316e6" title="Get this sprite&#39;s current X position, in pixels.">x</a>, <span class="keywordtype">int</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a5e181367a4c02d509069b74e8a34ca88" title="Get this sprite&#39;s current Y position, in pixels.">y</a>)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;        _SYS_vbuf_spr_move(&amp;sys-&gt;vbuf, <span class="keywordtype">id</span>, x, y);</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;    }</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;</div>
<div class="line"><a name="l00169"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a183e9aeb023742bee82a5fba49976232">  169</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a183e9aeb023742bee82a5fba49976232" title="Move this sprite to a new location, in pixels, passed as an Int2.">move</a>(<a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">Int2</a> pos)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;        <a class="code" href="struct_sifteo_1_1_sprite_ref.html#ac3c4d07b15caa0eecb715555b106709f" title="Move this sprite to a new location, in pixels.">move</a>(pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a>, pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>);</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;    }</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;</div>
<div class="line"><a name="l00181"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#ad60e4fe649800c49e56b562f3490bee9">  181</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#ad60e4fe649800c49e56b562f3490bee9" title="Move this sprite to a new location, in pixels, passed as a Float2.">move</a>(<a class="code" href="struct_sifteo_1_1_vector2.html">Float2</a> pos)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;        <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">Int2</a> i = pos.<a class="code" href="struct_sifteo_1_1_vector2.html#a7995e139a1436a81b9ae11e05701dabf" title="Round a floating point vector to the nearest integer.">round</a>();</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;        <a class="code" href="struct_sifteo_1_1_sprite_ref.html#ac3c4d07b15caa0eecb715555b106709f" title="Move this sprite to a new location, in pixels.">move</a>(i.<a class="code" href="struct_sifteo_1_1_vector2.html#a7362956454caca88012382934a1e94b9" title="Vector component X.">x</a>, i.<a class="code" href="struct_sifteo_1_1_vector2.html#a6ef946409dc8f1fb0fb21f158ad12bec" title="Vector component Y.">y</a>);</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;    }</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;</div>
<div class="line"><a name="l00189"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a8cf628cb56a69225c2d92f69fce316e6">  189</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a8cf628cb56a69225c2d92f69fce316e6" title="Get this sprite&#39;s current X position, in pixels.">x</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;        uint16_t addr = ( <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, spr[0].pos_x) +</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;                          <span class="keyword">sizeof</span>(_SYSSpriteInfo) * <span class="keywordtype">id</span> );</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;        <span class="keywordflow">return</span> -(int8_t)_SYS_vbuf_peekb(&amp;sys-&gt;vbuf, addr);</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;    }</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;</div>
<div class="line"><a name="l00198"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#a5e181367a4c02d509069b74e8a34ca88">  198</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#a5e181367a4c02d509069b74e8a34ca88" title="Get this sprite&#39;s current Y position, in pixels.">y</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;        uint16_t addr = ( <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, spr[0].pos_y) +</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;                          <span class="keyword">sizeof</span>(_SYSSpriteInfo) * <span class="keywordtype">id</span> );</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;        <span class="keywordflow">return</span> -(int8_t)_SYS_vbuf_peekb(&amp;sys-&gt;vbuf, addr);</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;    }</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;</div>
<div class="line"><a name="l00207"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_ref.html#aabf8e951b78a083e076a460a87975f35">  207</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_vector2.html" title="Generalized two-element cartesian coordinate vector.">Byte2</a> <a class="code" href="struct_sifteo_1_1_sprite_ref.html#aabf8e951b78a083e076a460a87975f35" title="Get this sprite&#39;s current position as a vector, in pixels.">position</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;        uint16_t addr = ( <a class="code" href="group__macros.html#gafef9199621fafa1bd046611921ab061f">offsetof</a>(_SYSVideoRAM, spr[0].pos_y)/2 +</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;                          <span class="keyword">sizeof</span>(_SYSSpriteInfo)/2 * <span class="keywordtype">id</span> );</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;        uint16_t word = _SYS_vbuf_peek(&amp;sys-&gt;vbuf, addr);</div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;        <span class="keywordflow">return</span> vec&lt;int8_t&gt;(-(int8_t)(word &gt;&gt; 8), -(int8_t)word);</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    }</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;    <span class="comment">// Next sprite ID</span></div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;    <a class="code" href="struct_sifteo_1_1_sprite_ref.html" title="SpriteRefs refer to a single sprite on a single cube.">SpriteRef</a> operator++ () {</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;        ++id;</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;        <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;    }</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;    <span class="comment">// Next sprite ID</span></div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;    SpriteRef operator++ (<span class="keywordtype">int</span>) {</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;        SpriteRef result = *<span class="keyword">this</span>;</div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;        ++id;</div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;        <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;    }</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;</div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;    <span class="comment">// Previous sprite ID</span></div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;    SpriteRef operator-- () {</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;        --id;</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;        <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;    }</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;    <span class="comment">// Previous sprite ID</span></div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;    SpriteRef operator-- (<span class="keywordtype">int</span>) {</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;        SpriteRef result = *<span class="keyword">this</span>;</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;        --id;</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;        <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;    }</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;    <span class="comment">// Calculate a new SpriteRef with an ID relative to this one</span></div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;    SpriteRef operator[] (<span class="keywordtype">int</span> index) {</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;        SpriteRef result = *<span class="keyword">this</span>;</div>
<div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;        result.id += index;</div>
<div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;        <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;    }</div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;};</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;</div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;</div>
<div class="line"><a name="l00259"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_layer.html">  259</a></span>&#160;<span class="keyword">struct </span><a class="code" href="struct_sifteo_1_1_sprite_layer.html" title="A SpriteLayer represents the VRAM attributes for the sprite rendering layer in BG0_SPR_BG1 mode...">SpriteLayer</a> {</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;    _SYSAttachedVideoBuffer sys;</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;    <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> NUM_SPRITES = _SYS_VRAM_SPRITES;</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;</div>
<div class="line"><a name="l00273"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_layer.html#a29fce2c5bdcd16055f6a8500cf357249">  273</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_sprite_ref.html" title="SpriteRefs refer to a single sprite on a single cube.">SpriteRef</a> <a class="code" href="struct_sifteo_1_1_sprite_layer.html#a29fce2c5bdcd16055f6a8500cf357249" title="Return a SpriteRef which references a single sprite on a single VideoBuffer.">operator[]</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">id</span>) {</div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;        <a class="code" href="group__macros.html#ga8a15779356736a0900a162442b1cda53" title="Runtime debug assertion.">ASSERT</a>(<span class="keywordtype">id</span> &lt; NUM_SPRITES);</div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;        <a class="code" href="struct_sifteo_1_1_sprite_ref.html" title="SpriteRefs refer to a single sprite on a single cube.">SpriteRef</a> result = { &amp;sys, <span class="keywordtype">id</span> };</div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;        <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;    }</div>
<div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;</div>
<div class="line"><a name="l00282"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_layer.html#afbd085a4d5dcb2e593b3d8b808d9a0d3">  282</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="struct_sifteo_1_1_sprite_layer.html#afbd085a4d5dcb2e593b3d8b808d9a0d3" title="Reset all sprites to their default hidden state.">erase</a>() {</div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;        _SYS_vbuf_fill(&amp;sys.vbuf, _SYS_VA_SPR / 2, 0,</div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;            <span class="keyword">sizeof</span>(_SYSSpriteInfo) / 2 * NUM_SPRITES);</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;    }</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;    </div>
<div class="line"><a name="l00290"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_layer.html#aa77ca74e087381cfa42e34c29082a282">  290</a></span>&#160;    _SYSVideoBuffer &amp;<a class="code" href="struct_sifteo_1_1_sprite_layer.html#aa77ca74e087381cfa42e34c29082a282" title="Return the VideoBuffer associated with this drawable.">videoBuffer</a>() {</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;        <span class="keywordflow">return</span> sys.vbuf;</div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;    }</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;</div>
<div class="line"><a name="l00297"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_sprite_layer.html#ae4c2368cfd5c6a9916d5ca4d7d0f84ca">  297</a></span>&#160;    <a class="code" href="struct_sifteo_1_1_cube_i_d.html" title="A lightweight identifier for one Sifteo cube.">CubeID</a> <a class="code" href="struct_sifteo_1_1_sprite_layer.html#ae4c2368cfd5c6a9916d5ca4d7d0f84ca" title="Return the CubeID associated with this drawable.">cube</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;        <span class="keywordflow">return</span> sys.cube;</div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;    }</div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;};</div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;</div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;};  <span class="comment">// namespace Sifteo</span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
    <hr class="footer"/>
    <address class="footer">
        <p><a href="http://sifteo.com">Sifteo</a> SDK v1.0.0 <small>(see <a href="https://developers.sifteo.com/sifteosdk">all versions</a>)</small></p>
        <p>Last updated Wed Mar 27 2013, by <a href="http://www.stack.nl/~dimitri/doxygen">Doxygen</a></p>
    </address>
</body>
</html>
